package com.econ.powercloud.ems.rpc;

import com.econ.powercloud.common.base.facade.pojo.MsgResult;
import com.econ.powercloud.console.facade.domain.*;
import com.econ.powercloud.common.base.facade.pojo.PageResult;
import com.econ.powercloud.ems.rpc.callback.IFeignPowerNodeConsoleFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * @Author : zjf
 * @Description : powernode-console feign接口
 * @Date : 2022/7/15 16:59
 * @Modified by : zjf
 */
@FeignClient(name = "powernode-console-server",/*url = "192.168.87.18:8085",*/fallbackFactory = IFeignPowerNodeConsoleFallbackFactory.class)
public interface IFeignPowerNodeConsoleClient {

    /**
     * @param msgId: 消息通讯id
     * @param deviceCode: iot设备编号
     * @param dit：遥控点号
     * @param value: 下发值
     * @param preSend: 是否生成记录但不发送，true:表示是,false表示否
     * 消息通讯id与是否是否生成记录但不发送一共有三种情况
     * 情况1：msgId为null,preSend为false,这种就是直接下发,返回结果是消息通讯id
     * 情况2: msgId为null,preSend为true,这种就是生成发送记录，但是不发送，之后需要再通过返回的msgId在下发一次
     * 情况3：msgId不为null,preSend为false,这种就是对已生成发送记录的数据(需提前执行情况2)，进行真正的遥控下发操作
     * @return
     */
    @PostMapping(value = "/svc/v2/edge/push/yk")
    MsgResult<Integer> yk(@RequestParam(value = "clientIp",required = false) String clientIp,
                          @RequestParam(value = "msgId",required = false) Integer msgId,
                           @RequestParam String deviceCode,
                           @RequestParam String dit,
                           @RequestParam Integer value,
                           @RequestParam Boolean preSend);

    /**
     * @param msgId: 消息通讯id
     * @param deviceCode: iot设备编号
     * @param dit：遥调点号
     * @param value: 下发值
     * @param preSend: 是否生成记录但不发送，true:表示是,false表示否
     * 消息通讯id与是否是否生成记录但不发送一共有三种情况
     * 情况1：msgId为null,preSend为false,这种就是直接下发,返回结果是消息通讯id
     * 情况2: msgId为null,preSend为true,这种就是生成发送记录，但是不发送，之后需要再通过返回的msgId在下发一次
     * 情况3：msgId不为null,preSend为false,这种就是对已生成发送记录的数据(需提前执行情况2)，进行真正的遥调下发操作
     * @return
     */
    @PostMapping(value = "/svc/v2/edge/push/yt")
    MsgResult<Integer> yt(@RequestParam(value = "clientIp",required = false) String clientIp,
                          @RequestParam(value = "msgId",required = false) Integer msgId,
                          @RequestParam String deviceCode,
                          @RequestParam String dit,
                          @RequestParam Double value,
                          @RequestParam Boolean preSend);

    @PostMapping(value = "/svc/v2/edge/push/strategy/{deviceCode}")
    MsgResult<Integer> strategy(@RequestParam(value = "clientIp",required = false) String clientIp,
                                @PathVariable String deviceCode,
                                       @RequestBody EdgeStrategyRequestVO requestVO);

    /**
     * 获取操作记录下的客户端ip
     * @return
     */
    @PostMapping("/svc/v2/syncMsg/searchClientIp")
    MsgResult<List<String>> searchClientIp();

    @PostMapping("/svc/v2/syncMsg/search")
    MsgResult<PageResult<List<EdgePlatformSyncMsgVO>>> searchDeviceOperationRecord(@RequestBody EdgePlatformSyncMsgSearchRequestVO requestVO);

    @GetMapping("/svc/v2/syncMsg/{msgPid}")
    MsgResult<EdgePlatformSyncMsgDetailVO> msgDetails(@PathVariable("msgPid") Integer msgPid);

    /**
     * 召唤历史保护事件
     * @param start: 起始事件编号
     * @param end: 终止事件编号
     */
    @PostMapping(value = "/svc/v2/edge/push/callHisPg")
    MsgResult<Integer> callHisPg(@RequestParam(value = "clientIp",required = false) String clientIp,
                                 @RequestParam String deviceCode, @RequestParam Integer start, @RequestParam Integer end);

    /**
     * 召唤历史SOE事件
     * @param start: 起始事件编号
     * @param end: 终止事件编号
     */
    @PostMapping(value = "/svc/v2/edge/push/callHisSoe")
    MsgResult<Integer> callHisSoe(@RequestParam(value = "clientIp",required = false) String clientIp,
                                  @RequestParam String deviceCode, @RequestParam Integer start, @RequestParam Integer end);

    /**
     * 获取云端设置信息
     */
    @GetMapping(value = "/svc/v2/cloud/control")
    MsgResult<CloudControlVO> search();

    /**
     * 下发云端控制
     */
    @PostMapping("/svc/v2/cloud/control/push/cloudSwitch")
    MsgResult<Integer> cloudSwitch(@RequestParam(value = "clientIp",required = false) String clientIp,
                                   @RequestParam Integer onoff);

    /**
     * 获取主备切换信息
     */
    @GetMapping("/svc/v2/masterSlave")
    public MsgResult getInfo();

    @PutMapping("/svc/v2/masterSlave")
    public MsgResult modifyAccessMethod(@RequestBody @Validated SysMasterSlaveEdit edit);

    /**
     * 挂牌下发
     * @param deviceCode
     * @param type
     * @param value
     * @return
     */
    @PostMapping(value = "/svc/v2/edge/push/listing")
    MsgResult<Integer> pushListing(@RequestParam String deviceCode,
                                   @RequestParam Integer type,
                                   @RequestParam Integer value);
}
